//
//  DoctorDetailCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/26.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

protocol DoctorDetailCellDelegate: NSObjectProtocol {
    func didClickedReserveDoctor(_ cell: DoctorDetailCell)
}

class DoctorDetailCell: UITableViewCell {

    weak var delegate: DoctorDetailCellDelegate?
    
    func configure(with vm: DoctorScheduleViewModel) {
        timeLabel.text = vm.scheduleTime
        costLabel.text = "￥\(vm.regFee)"
        statusBtn.isEnabled = false
        statusBtn.setTitle(vm.status.statusText, for: .normal)
        statusBtn.setTitleColor(vm.status.statusTextColor, for: .normal)
        statusBtn.setBackgroundImage(vm.status.backgroundImage, for: .disabled)
        
        timeLabel.textColor = vm.status.textColor
        costLabel.textColor = vm.status.statusTextColor
        
        departmentLabel.text = vm.departmentName
    }
    
    @IBOutlet private weak var departmentLabel: UILabel!
    @IBOutlet private weak var timeLabel: UILabel!
    
    @IBOutlet private weak var costLabel: UILabel!
    
    @IBOutlet private weak var statusBtn: UIButton! {
        didSet {
            statusBtn.layer.cornerRadius = statusBtn.height * 0.5
            statusBtn.layer.masksToBounds = true
        }
    }
    
    @IBAction private func statusBtnClicked(_ sender: UIButton) {
        delegate?.didClickedReserveDoctor(self)
    }
}
